#pragma once

#ifndef _MODEL_H_
#define _MODEL_H_
#ifdef WIN32
#pragma execution_character_set("utf-8")
#endif

#include <qdebug.h>
#include <qobject.h>
#include <qdatetime.h>
#include <qstring.h>
#include <opencv2\opencv.hpp>
#include "idProducer.h"
#include "configuration.h"

/// <summary>
/// 检测结果
/// </summary>
typedef struct {

	//double area = 0.0;              //烟具或者烟弹面积

	//double warningArea = 0.0;       //警语区域面积

	//std::vector<double> lineWidth;  //分割线宽度

	//std::vector<int> textCount;		//文字数量

	//std::vector<double> textHeight; //字体高度

	//double textArea = 0.0;          //文字面积

	//cv::Mat markImg;                //标注图像

	double maxHeight = 0.0;       //薄膜表面最大高度

	double minHeight = 0.0;       //薄膜表面最小高度

	double meanHeight=0.0;       //薄膜表面平均高度

	double heightSD = 0.0;       //标准方差

	double abnormalArea = 0.0;    //薄膜异常区域-荷叶边



} DetectResult;


/// <summary>
/// 数据库模型
/// </summary>
namespace DaoModel {

	/// <summary>
	/// 牌号，班次，检测员的父类
	/// </summary>
	class StringParams {

	public:

		/// <summary>
		/// 初始化对象
		/// </summary>
		StringParams();

		/// <summary>
		/// 获取ID
		/// </summary>
		/// <returns></returns>
		const qint64& id() { return m_id; }


		/// <summary>
		/// 获取名称
		/// </summary>
		/// <returns></returns>
		const QString& name() { return m_name; };

		/// <summary>
		/// 获取最近一次使用时间
		/// </summary>
		/// <returns></returns>
		const QDateTime& lastUseTime() { return m_lastUseTime; };


		/// <summary>
		/// 获取最近一次使用时间字符串
		/// </summary>
		/// <param name="format"></param>
		/// <returns></returns>
		QString lastUseTimeStr(QString& format = QString("yyyy-MM-dd HH:mm:ss")) { return m_lastUseTime.toString(format); };


		/// <summary>
		/// 设置ID
		/// </summary>
		/// <param name="id"></param>
		void setId(qint64 id);

		/// <summary>
		/// 设置名称
		/// </summary>
		/// <param name="name"></param>
		void setName(QString name);

		/// <summary>
		/// 以时间戳的方式设置时间
		/// </summary>
		/// <param name="time"></param>
		void setLastUseTime(qint64 time);

		/// <summary>
		/// 以字符串的形式设置时间
		/// </summary>
		/// <param name="time">时间字符串</param>
		/// <param name="format">格式化字符串</param>
		void setLastUseTime(QString& time, QString& format = QString("yyyy-MM-dd HH:mm:ss"));

	protected:

		//编号
		qint64 m_id;

		//班次名称
		QString m_name;

		//上次使用时间
		QDateTime m_lastUseTime;

	};


	/// <summary>
	/// 牌号
	/// </summary>
	class Brand : public StringParams {

	public:

		Brand() : StringParams() {};

		Brand(QString name) { this->m_name = name; }

	};


	/// <summary>
	/// 班次
	/// </summary>
	class Schedule : public StringParams {

	public:

		Schedule() : StringParams() {};

		Schedule(QString name) { this->m_name = name; }

	};


	/// <summary>
	/// 检测员
	/// </summary>
	class Tester : public StringParams {

	public:

		Tester() : StringParams() {};

		Tester(QString name) { this->m_name = name; }

	};


	/// <summary>
	/// 检测数据
	/// </summary>
	class TestData {

	public:

		TestData();

		TestData(QString tester, QString schedule, QString brand, QString num,DetectResult& data);

		~TestData() { };

		//获取id
		const qint64& id() { return m_id; };

		//获取牌号
		const QString& brand() { return m_brand; };

		//获取检测员
		const QString& tester() { return m_tester; };

		//获取班次
		const QString& schedule() { return m_schedule; };

		//获取样本编号
		const QString& num() { return m_num; };

		//获取薄膜检测高度
		const double& maxHeight(){return m_maxHeight;};

		//薄膜最低点
		const double& minHeight(){return m_minHeight;};

		//薄膜表面平均高度
		const double& meanHeight() { return m_meanHeight; };

		//薄膜检测数据标准方差
		const double& heightSD() { return m_heightSD; };

		//薄膜异常区域-荷叶边
        const double& abnormalArea() { return m_abnormalArea; };

		////获取检测的面
		//const QString& name() { return m_name; };

		////获取样本面积
		//const double area() { return m_area; };

		////获取样本警语面积
		//const double warningArea() { return m_warningArea; };

		////获取警语区面积占比
		//const double warningAreaRatio() { return (m_area > 0 ? m_warningArea / m_area * 100.00f : 0.0); };

		////获取分割线宽度
		//const QString lineWidth() { return m_lineWidth.isEmpty() ? "" : m_lineWidth; };
		//
		//const int textCount() { return m_textCount; };

		////获取字体高度
		//const QString textHeight() { return m_textHeight.isEmpty() ? "" : m_textHeight; };

		////获取文字面积
		//const double textArea() { return m_textArea; };

		////获取文字面积占比
		//const double textAreaRatio() { return (m_warningArea > 0 ? m_textArea / m_warningArea * 100.00f : 0.0); };
		
		//获取检测时间
		const QDateTime& createTime() { return m_createTime; };



		//设置数据库记录编号
		void setId(qint64 id);

		//修改检测员
		void setTester(QString val);

		//修改班次
		void setSchedule(QString val);

		//修改牌号
		void setBrand(QString val);

		//设置样本编号
		void setNum(QString num);

		//设置样本名称
		//void setName(QString name);

		//设置薄膜最高高度
		void setMaxHeight(double maxHeight);

		//设置薄膜最低点
		void setMinHeight(double minHeight);

		//设置薄膜表面平均高度
        void setMeanHeight(double meanHeight);

		//设置薄膜高度标准方差
		void setHeightSD(double heightSD);

		//设置薄膜异常区域-荷叶边
		void setAbnormalArea(double abnormalArea);

		////设置烟具面积
		//void setArea(double area);

		////设置警语区面积
		//void setWarningArea(double area);

		////设置分割线宽度
		//void setLineWidth(QString val);

		////设置分割线宽度，传入的是实数
		//void setLineWidth(vector<double>& valList);

		////设置字体高度
		//void setTextCount(vector<int>& valList);

		////设置字体高度
		//void setTextCount(int val);

		////设置字体高度
		//void setTextHeight(QString val);
		//
		////以传入的实数设置文字高度
		//void setTextHeight(vector<double>& valList);
		//
		////设置文字面积
		//void setTextArea(double val);

		//设置检测时间
		void setCreateTime(QDateTime& time);

		//打印数据
		const QString toString() const;



	private:

		//数据ID
		qint64 m_id;
		//检测员
		QString m_tester;
		//班次
		QString m_schedule;
		//牌号
		QString m_brand;
		//样本编号
		QString m_num;

		//薄膜最高高度
		double m_maxHeight=0.0;

		//薄膜最低点
		double m_minHeight = 0.0;

		//薄膜表面平均高度
		double m_meanHeight = 0.0;

		//薄膜高度数据标准方差
		double m_heightSD = 0.0;

		//薄膜异常区域-荷叶边  
		double m_abnormalArea = 0.0;

		////检测面
		//QString m_name;
		////烟具或者烟弹面积
		//double m_area = 0.0;
		////警语区域面积
		//double m_warningArea = 0.0;
		////分割线宽度
		//QString m_lineWidth;
		////文字数量
		//int m_textCount = 0;
		////字体高度
		//QString m_textHeight;
		////文字面积
		//double m_textArea = 0.0;
		//添加时间
		QDateTime m_createTime;
	};

}

#endif